/*
 * @Author: your name
 * @Date: 2020-01-04 19:56:22
 * @LastEditTime : 2020-01-06 00:50:20
 * @LastEditors  : Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: /nest-app/src/main.ts
 */
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { NestExpressApplication } from '@nestjs/platform-express';
import { join } from 'path';
import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';
import { Transport } from '@nestjs/common/enums/transport.enum';

const swaggerOptions = new DocumentBuilder()
  .setTitle('api文档')
  .setDescription('文档')
  .setVersion('1.0')
  .build();

const app1 = NestFactory.createMicroservice(AppModule, {
  transport: Transport.RMQ,
  options: {
    urls: [`amqp://localhost:5672`],
    queue: 'cats_queue',
    queueOptions: { durable: false },
  },
});
async function bootstrap() {
  const app = await NestFactory.create<NestExpressApplication>(AppModule);
  app.useStaticAssets('public');
  // 虚拟目录
  app.useStaticAssets(join(__dirname, '..', 'dist'), { prefix: '/static/' });
  const document = SwaggerModule.createDocument(app, swaggerOptions);
  SwaggerModule.setup('api-docs', app, document);
  await app.listen(3001);
}
bootstrap();
